package com.qilin.hammer.util.database;

import java.sql.Connection;
import java.sql.DriverManager;

public class OracleDBConnection extends DBConnection {
    
	private final static String DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
	
	@Override
	public Connection getConnection(String ip, String port, String uname, String pwd){
    	this.hostaddress = ip;
    	this.portnum = port;
    	this.db_username = uname;
    	this.db_password = pwd;
    	this.db_url = "jdbc:oracle:thin:@"+hostaddress+":"+portnum+":orcl";
        /** 声明Connection连接对象*/
        Connection conn = null;
        try{
            /** 使用Class.forName()方法自动创建这个驱动程序的实例且自动调用DriverManager来注册它*/
            Class.forName(DB_DRIVER);
            /** 通过DriverManager的getConnection()方法获取数据库连接*/
            conn = DriverManager.getConnection(db_url,db_username,db_password);
            if(conn != null)
            	System.out.println("Oracle database connection to "+ip+" and user "+uname+" is successful!");
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return conn;
	}
	

}
